<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
     .box {
            margin: 100px;
            width: 460px;
            margin: 100px auto;
        }

        .box .btn {
            height: 40px;
            margin-bottom: 5px;
        }

        .box .btn input {
            float: left;
            width: 100px;
            text-align: center;
            height: 40px;
            margin-right: 20px;
            border: 1px solid #334455;
        }

        .box .btn input:nth-child(4) {
            margin-right: 0px;
        }

        .box .con {
            width: 460px;
            height: 400px;
            border: 1px solid #ccc;
            box-sizing: border-box;
            display: none;
        }

        .box .btn .active {
            background: skyblue;
        }
</style>
<body>
    <!-- 实现选项卡 -->
    <div class="box">
        <div class="btn">
            <input type="button" class="btnList active" value="体育">
            <input type="button" class="btnList" value="娱乐">
            <input type="button" class="btnList" value="新闻">
            <input type="button" class="btnList" value="游戏">
        </div>
        <div class="con" style="display: block;">体育</div>
        <div class="con">娱乐</div>
        <div class="con">新闻</div>
        <div class="con">游戏</div>
    </div>

    <script>
        //获取元素
        var btn=document.getElementsByTagName('input')
        var con=document.getElementsByClassName('con')

        for(var i=0;i<btn.length;i++){
            btn[i].idx = i
            btn[i].onclick=function(){
                for(var j=0;j<btn.length;j++){
                    btn[j].className='btnList'
                    con[j].style.display='none'
                    this.className='btnList active'
                    con[this.idx].style.display='block'
                }

                
                
            }
        }

    </script>
</body>
</html>